<template>
  <view>
    <mask-layer :visible.sync="modalVislble" />

    <view class="m-modal" :style="mModalClass()">
      <template v-if="modalVislble">
        <view class="content">
          {{ displayContent }}
        </view>
        <view class="btn">
          <view class="close" @tap="close">
            取消
          </view>
          <view v-if="!modalLoading" class="submit" @tap="submit">
            确定
          </view>
          <view v-else class="submit">
            <uni-icons class="rotate-box" type="spinner-cycle" size="30" color="#ffffff" />
          </view>
        </view>
      </template>
    </view>
  </view>
</template>

<script>
import { getFiles } from "@/utils/getFiles";
const files = require.context("./mixins", false, /\.js$/);
const mixins = getFiles(files);

import message from "$common/mixins/message"
export default {
  name: "MModal",
  mixins: [...mixins, message],
  props: {
    // 异步确定 (需要调用接口的为异步确定)
    asyncConfirm: {
      type: Boolean,
      default: true,
    },
    // 是否可见
    visible: {
      type: Boolean,
      default: true,
    },
    // 内容
    content: {
      type: String,
      default: "",
    },
    // 当前使用api标识
    useFlag: {
      type: [Number, String],
      default: -1,
    },
    // 请求api
    apis: {
      type: Array,
      default: () => [],
    },
    // 请求是携带参数
    params: {
      type: Object,
      default: () => {
        return {
          id: null
        }
      }
    },
    // 选择可使用数据
    selectRowData: {
      type: Object,
      default: () => { },
    },
  },
  watch: {
    visible(value) {
      this.modalVislble = value;
    },
    modalVislble(value) {
      this.$emit("update:visible", value);
    },
  },

};
</script>

<style lang="scss" src="./index.scss" scoped></style>
